<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
</body>
<script>

  //定义函数
  function getMax(arr){
    var minPrice = 7;
    var maxMoney = 0;
    var money = 0;
    for(var i = 1; i < arr.length; i++){
      var item = arr[i];
      money = item - minPrice;
      minPrice = Math.min(item, minPrice);
      maxMoney = Math.max(money, maxMoney);
    }
    return maxMoney;
  }

  var arr = prompt("请输入一个数组，英文逗号分隔");
  alert(getMax(arr.split(",")));
</script>
</html>